<?php
	//1.登录
	//获取用户名和密码
	$userName = $_GET['un'];
	$passWord = $_GET['pw'];
	
	//1.链接数据库
	$link = mysqli_connect('127.0.0.1','root','root','sn');
	
	//2.执行操作
	$sql = "SELECT * FROM `userinfo` WHERE `userName` = '$userName' AND `passWord` = '$passWord'";
	
	//3.解析结果
	$result = mysqli_query($link,$sql);
	//由于只有一行就用扫描一行这个方法
	$arr=  mysqli_fetch_assoc($result);
//	$jsonStr = json_encode($arr);
//	var_dump($arr);
	if($arr){
		$ar = array('code' => 1);
		echo json_encode($ar);
	}else{
		//登录失败,跳转登录页面重新填写
//		header('location:longin.html');
		$ar = array('code' => 0);
		echo json_encode($ar);
	}
	//4.断开链接
	mysqli_close($link);
?>